!pr1
Which Processor Am I In?.......................Jim Poponoe

One of the first programs I wrote after receiving my 65802 chip was one which tells me which microprocessor is in my Apple.  Since the 65C02 has instructions not in the 6502, and since the 65802 has all of those and still more, it is possible to tell which is which.

The instructions in the 65802 (or 65816) which are not in the 65C02 are all "no-operation" opcodes in the 65C02.  The same is not true for the un-implemented codes in the 6502!  Bob S-C detailed what all the un-implemented 6502 opcodes do in the March 1981 issue of AAL.  Some of them do really exotic things, but some are in fact NOPs.  $80 is a two-byte NOP in the 6502, but a Branch Always (BRA) in the 65C02 and 658xx.  Therefore, the BRA opcode can be used to distinguish between the 6502 and higher versions.

The XBA instruction ($EB) is a one-byte no-operation in the 65C02.  In the 658xx it exchanges the low and high bytes of the 16-bit A-register.  Therefore it can be used to distinguish between the 65C02 and the 658xx processors.

The following program will print out either "6502", "65C02", or "65802" depending on which it finds.  A few more tests could distinguish the Rockwell 65C02, which has four opcodes beyond those in 65C02s made by other manufacturers.  And a few more might distinguish between a 65802 in my motherboard and a 65816 running in a co-processor card.  I'll leave those for interested readers to try.
